package com.nbst.controller.api;

import javax.servlet.http.HttpServletRequest;

import com.nbst.annotation.OperLog;
import com.nbst.model.api.RequestModel;
import com.nbst.service.api.impl.OpenApiServiceImpl;

import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.json.JSONObject;

/**
 * @author wangwt
 * @description 对外API接口
 * @since 2020-10-13
 **/
@RestController
@CrossOrigin
@RequestMapping("/open/api")
public class OpenApiController {

    @Autowired
    OpenApiServiceImpl openApiService;

    @Autowired
    HttpServletRequest request;

    @RequestMapping("/mes.action")
    @OperLog(operModule = "对外API", operType = "WMS反馈", operDesc = "WMS反馈")
    public Object sendOpenRequest(@RequestBody RequestModel requestModel) {
        return openApiService.sendOpenRequest(requestModel, request);
    }

    @RequestMapping("/huixie.action")
    public Object huixie(@RequestBody JSONObject str) throws JSONException {
        return openApiService.wmsOrderReturn(str);
    }
}
